package br.com.rhweb.modelos;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.GenericGenerator;

import br.com.rhweb.util.Util;

@Entity
@Table(name="tbl_usuario")
public class Usuario implements Serializable{
	/*
	@Id
	@GeneratedValue(generator = "increment")
	@GenericGenerator(name = "increment", strategy = "increment")
	@Column(name="id_usuario")
	private int id;
	*/
	
	@Column(name="nome_usuario")
	private String name;
	
	@Id
	@Column(name="username")
	private String user;
	
	@Column(name="password")
	private String password;
	
	@Column(name="enable")
	private boolean ativo;
	
	@OneToMany(mappedBy="permissoesPK.usuario", cascade=CascadeType.ALL)
	private List<Permissoes> permissoes;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = Util.encryptar(password);
	}

	public boolean isAtivo() {
		return ativo;
	}

	public void setAtivo(boolean ativo) {
		this.ativo = ativo;
	}

	public List<Permissoes> getPermissoes() {
		return permissoes;
	}

	public void setPermissoes(List<Permissoes> permissoes) {
		this.permissoes = permissoes;
	}
	
}
